﻿using UnityEngine;
using System.Collections;

public class MoveCube : MonoBehaviour {
	SquareEnemy squareEnemy;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (transform.renderer.enabled) {
			int randomDirection = Random.Range (0, 4);
			Vector3 moveVector;
			if (randomDirection == 0) {	//right
					moveVector = new Vector3 (transform.position.x + 0.2f, transform.position.y, 0f);
			} else if (randomDirection == 1) {	//up
					moveVector = new Vector3 (transform.position.x, transform.position.y + 0.2f, 0f);
			} else if (randomDirection == 2) {	//left
					moveVector = new Vector3 (transform.position.x - 0.2f, transform.position.y, 0f);
			} else {	//down
					moveVector = new Vector3 (transform.position.x, transform.position.y - 0.2f, 0f);
			}
			if (!(moveVector.x > 6.0f || moveVector.x < -6.0f || moveVector.y > 4.0f || moveVector.y < -4.0f)) {
				transform.position = moveVector;
			}
		}
	}
}
